<template>
	<view>
		<!-- v-show是display:none -->
		<view v-show="false">v-show</view>
		<!-- v-if是删除 -->
		<view v-if="false">v-if</view>
		<view v-for="(item, index) in list" :key="index" style="height: 150rpx;">{{ item }}</view>
		<button @click="pullDown">点击按钮下拉刷新</button>
		<button @click="getRequest">获取get请求</button>
		<button @click="setStorage">存储</button>
		<button @click="getStorage">获取</button>
		<button @click="removeStorage">移除 id</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: ['java', 'javascript', 'vue', 'react', 'java', 'javascript', 'vue', 'react', 'java']
			};
		},
		onLoad() {
			console.log('页面初始化 执行一次 onLoad')
		},
		onReady() {
			console.log('页面加载完毕 执行一次 onReady')
		},
		onShow() {
			console.log('页面进入执行 执行多次 onShow')
		},
		onHide() {
			console.log('页面进入离开 执行多次 onHide')
		},
		onPullDownRefresh() {
			console.log('页面下拉动作 onPullDownRefresh')
			setTimeout(() => {
				this.list = ['css', 'scss', 'less']
				uni.stopPullDownRefresh()
			}, 2000)
		},
		onTabItemTap() {
			console.log('用户点击 tabber')
		},
		onShareAppMessage() {
			console.log('用户点击了分享')
			return {
				title: '我是分享',
				path: 'pages/new/news',
				imageUrl: '../../static/img/logo.png'
			}
		},
		onReachBottom() {
			console.log('触底了')
			this.list = [...this.list, ['hahaha', 'yyyyyyy', 'eeeeeee']]
		},
		methods: {
			pullDown() {
				uni.startPullDownRefresh()
			},
			getRequest() {
				uni.request({
					url: 'http://172.16.54.133:8001/strategy/configuration/process',
					success: (res) => {
						console.log(res)
					}
				})
			},
			setStorage() {
				// uni.setStorage({
				// 	key: 'id',
				// 	data: 80,
				// 	success() {
				// 		console.log('存储成功')
				// 	}
				// })
				uni.setStorageSync('id', 1000)
			},
			getStorage() {
				// uni.getStorage({
				// 	key: 'id',
				// 	success: res => {
				// 		console.log('获取成功', res.data)
				// 	}
				// })
				console.log(uni.getStorageSync('id'))
			},
			removeStorage() {
				// uni.removeStorage({
				// 	key: 'id',
				// 	success() {
				// 		console.log('移除成功')
				// 	}
				// })
				uni.removeStorageSync('id')
			}
		}
	}
</script>

<style lang="scss">

</style>
